package pswvclass.pswvandroid2.com.util;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import android.util.Log;

/**
 * Created by Administrator on 2019/1/10.
 */
public class DBHelper extends SQLiteOpenHelper {

    // 数据库文件名
    public static final String DB_NAME = "pswv_database.db";
    // 数据库表名
    public static final String TABLE_NAME = "user";
    // 数据库版本号
    public static final int DB_VERSION = 1;


    public static final String USERID = "userId";
    public static final String ACCOUNT = "account";
    public static final String PASSWORD = "password";
    public static final String STATE = "state";//状态表示1通过的 0未通过 2表示用户没被激活

    public DBHelper(Context context) {
        super(context, DB_NAME, null, DB_VERSION);
    }

    // 当数据库文件创建时，执行初始化操作，并且只执行一次
    @Override
    public void onCreate(SQLiteDatabase db) {
        // 建表
        String sql = "create table " + TABLE_NAME
                + "( userId integer ,"
                + "account varchar(60), "
                + "password varchar(60),"
                + "state integer)";
        db.execSQL(sql);
    }

    // 当数据库版本更新执行该方法
    @Override
    public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {

    }
}
